﻿@using Telerik.Blazor.Components.Grid
@using BlazorInRazorPages.Models

<h3>My DropDown</h3>


<TelerikRootComponent>
	@* This component must wrap the entire Blazor component when Telerik components are used in it
		more: https://docs.telerik.com/blazor-ui/getting-started/what-you-need#project-configuration *@
    @SelectedCustomerId
    <br />
	<TelerikDropDownList Data="@Customers" @bind-Value="@SelectedCustomerId" TextField="Name" ValueField="Id"></TelerikDropDownList>

</TelerikRootComponent>

@code {
    [Parameter]
    public IEnumerable<Customer> Customers { get; set; }

    private int SelectedCustomerId { get; set; } = 5;

    protected override void OnInitialized()
    {
        base.OnInitialized();
        if(Customers == null)
        {
            //we did not get data from the parent component/page, we will get (generate) some
            Customers = Enumerable.Range(1, 15).Select(x => new Customer { Id = x, Name = "Name " + x });
        }
    }
}
